//
//  ;
//  GameChooser
//
//  Created by LT-LT on 14-1-23.
//  Copyright (c) 2014年 moonwolf. All rights reserved.
//

#import "Admodel.h"

@implementation Admodel
@synthesize clickUrlList=_clickUrlList;
@synthesize picList=_picList;
@synthesize banner_path=_banner_path;
@synthesize banner_width = _banner_width;


- (id)initWithAttributes:(NSDictionary *)attributes
{
    self = [super init];
    if (!self) {
        return nil;
    }
    NSMutableArray *Mpiclist=[NSMutableArray arrayWithCapacity:4];
    NSMutableArray *Murllist=[NSMutableArray arrayWithCapacity:4];
    NSArray *appwall=[attributes valueForKey:@"barner"];
    for (int i =0; i<[appwall count]; i++) {
        NSDictionary *tempDic=appwall[i];
        NSURL *tempPic=[NSURL URLWithString:[tempDic valueForKey:@"Pic"]];
        [Mpiclist addObject:tempPic];
        NSURL *tempUrl=[NSURL URLWithString:[tempDic valueForKey:@"Url"]];
        [Murllist addObject:tempUrl];
    }
    _picList=Mpiclist;
    _clickUrlList=Murllist;
    NSArray *tempPop=[attributes valueForKey:@"pop"][0];
    NSLog(@"%@",tempPop);
    _popPic=[NSURL URLWithString:[tempPop valueForKey:@"Pic"]];
    _popUrl=[tempPop valueForKey:@"Url"];
    NSArray *asw=[attributes valueForKey:@"Switch"];
    NSString *bsw=asw[0];
    NSString *psw=asw[1];
    if ([bsw isEqualToString:@"on"]) {
        _barnerSwitch=YES;
    }
    if ([psw isEqualToString:@"on"]) {
        _popSwitch=YES;
    }
    
    return self;
}

- (NSArray *)getArrayfromString:(NSString *)str
{
    return  [str componentsSeparatedByString:@","];
}
@end
